package cloud.simple;

import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.annotation.PostConstruct;
import org.apache.log4j.PropertyConfigurator;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WatchClientConfig {

	@Value("${znode}")
	String znode;
	
	@Value("${times}")
	int times;
	
	@Value("${zookeeper.server.list}")
	String serverList;

	ExecutorService executor = Executors.newSingleThreadExecutor();

	// 构造方法之后，init()之前执行
	@PostConstruct
	public void init() throws IOException {
		PropertyConfigurator.configure("src/main/resources/log4j.properties");
		executor.execute(new WatchClient(serverList,znode,times));
	}
}
